package com.zjmzxfzhl.modules.purchase.controller;

import com.zjmzxfzhl.common.Result;
import com.zjmzxfzhl.common.base.BaseController;
import com.zjmzxfzhl.modules.purchase.controller.vo.MonthlyStatVo;
import com.zjmzxfzhl.modules.purchase.controller.vo.ProjectStatVo;
import com.zjmzxfzhl.modules.purchase.controller.vo.StatTotalVo;
import com.zjmzxfzhl.modules.purchase.controller.vo.SupplierStatVo;
import com.zjmzxfzhl.modules.purchase.service.PurchaseGeneralstatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Controller
 *
 * @author yangjf
 */
@RestController
@RequestMapping("/purchase/generalstat")
public class PurchaseGeneralstatController extends BaseController {
    @Autowired
    private PurchaseGeneralstatService purchaseGeneralstatService;

    /**
     * @return
     * @功能：查询日历内容
     */
    @GetMapping(value = "/total")
    public Result statTotal(@RequestParam(value = "startDate", required = false) String startDate,
                            @RequestParam(value = "endDate", required = false) String endDate) {
        StatTotalVo result = purchaseGeneralstatService.statTotal(startDate, endDate);
        return Result.ok(result);
    }

    /**
     * @return
     * @功能：统计供应商数据
     */
    @GetMapping(value = "/supplierStat")
    public Result statSupplier(@RequestParam(value = "startDate", required = false) String startDate,
                               @RequestParam(value = "endDate", required = false) String endDate) {
        List<SupplierStatVo> result = purchaseGeneralstatService.statSupplier(startDate, endDate);
        return Result.ok(result);
    }

    /**
     * @return
     * @功能：项目数据
     */
    @GetMapping(value = "/projectStat")
    public Result statProject(@RequestParam(value = "startDate", required = false) String startDate,
                              @RequestParam(value = "endDate", required = false) String endDate) {
        List<ProjectStatVo> result = purchaseGeneralstatService.statProject(startDate, endDate);
        return Result.ok(result);
    }

    /**
     * @return
     * @功能：月采购统计
     */
    @GetMapping(value = "/monthlyPurchaseStat")
    public Result statPurchaseMonthly(@RequestParam(value = "startDate", required = false) String startDate,
                                      @RequestParam(value = "endDate", required = false) String endDate) {

        List<MonthlyStatVo> result = purchaseGeneralstatService.statPurchaseMonthly(startDate, endDate);
        return Result.ok(result);
    }


}
